package personal.xjl._23java1studentdemo.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import personal.xjl._23java1studentdemo.mapper.CourseMapper;
import personal.xjl._23java1studentdemo.mapper.StudentMapper;
import personal.xjl._23java1studentdemo.model.Course;
import personal.xjl._23java1studentdemo.model.Student;
import personal.xjl._23java1studentdemo.service.CourseService;
import personal.xjl._23java1studentdemo.service.StudentService;

import java.util.List;

@Service  //类似于@Controller@Mapper,告诉spring容器帮忙创建一个service对象
public class CourseServiceImpl implements CourseService {
    @Autowired
    CourseMapper courseMapper;
    @Override
    public List<Course> findAll() {
        return courseMapper.selectAll();
    }

    @Override
    public int remove(int id) {
        return courseMapper.deleteById(id);
    }

    @Override
    public int add(Course course) {
        return courseMapper.insert(course);
    }

    @Override
    public Course findById(int id) {
        return courseMapper.selectById(id);
    }

    @Override
    public int edit(Course course) {
        return courseMapper.update(course);
    }

    @Override
    public List<Course> findByPage(int pageNo, int pageSize) {
        return courseMapper.selectByPage((pageNo-1)*pageSize, pageSize);
    }
}